package com.llt.system.controller.question;


import com.llt.common.core.domain.R;
import com.llt.common.core.domain.TableDataInfo;
import com.llt.system.domain.question.dto.QuestionAddDTO;
import com.llt.system.domain.question.dto.QuestionDetailVO;
import com.llt.system.domain.question.dto.QuestionEditDTO;
import com.llt.system.domain.question.dto.QuestionQueryDTO;
import com.llt.system.service.qusetion.IQuestionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/question")
@Tag(name = "题目管理接口")
public class QuestionController {

    @Autowired
    private IQuestionService questionService;

    /**
     * 查询问题列表
     */
    @GetMapping("/list")
    public TableDataInfo queryList(QuestionQueryDTO dto) {
        return questionService.list(dto);
    }

    /**
     * 添加问题
     */
    @PostMapping("/add")
    public R<Void> add(@RequestBody QuestionAddDTO dto) {
        return questionService.add(dto);
    }

    /**
     * 题目详情
     */
    @GetMapping("/detail")
    public R<QuestionDetailVO> detail(Long questionId) {
        return questionService.detail(questionId);
    }

    /**
     * 编辑题目
     */
    @PutMapping("/edit")
    public R<Void> edit(@RequestBody QuestionEditDTO dto) {
        return questionService.edit(dto);
    }

    /**
     * 删除题目
     */
    @DeleteMapping("/delete")
    public R<Void> delete(Long questionId) {
        return questionService.delete(questionId);
    }
}
